using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum StateType 
{
    Ground,
    InAir,
    TouchingWall,
    Ability,
    Global,
    Climb,
}

public class PlayerState 
{
    protected Player player;
    protected PlayerMoveData playerData;
    protected StateMachine stateMachine;
    protected string animName;

    public StateType stateType { get; protected set; }

    //input
    protected int xInput;
    protected int yInput;
    protected bool fastMoveInput;
    protected bool jumpInput;
    protected bool jumpInputStop;
    protected bool grabInput;
    protected bool scrollInput;
    protected bool dashInput;

    //check
    protected bool isLeftFootGrounded;
    protected bool isRightFootGrounded;
    protected bool isGrounded;
    protected bool isSingleFootGrounded;
    protected bool isTouchingCeiling;
    protected bool isTouchingWall;
    protected bool isTouchingLedge;

    //logic
    protected float stateEnterTime;
    protected Vector3 enterPos;
    protected bool isAnimationFinish;

    public PlayerState(Player player, PlayerMoveData playerData, StateMachine stateMachine, string animName) 
    {
        this.player = player;
        this.playerData = playerData;
        this.stateMachine = stateMachine;
        this.animName = animName;
    }

    public virtual void Enter() 
    {
        OnCheck();
        stateEnterTime = Time.time;
        player.animator.Play(animName);     
        isAnimationFinish = false;
        enterPos = player.transform.position;
    }

    public virtual void LogicUpdate() 
    {
        xInput = player.inputHandler.NormalInputX;
        yInput = player.inputHandler.NormalInputY;
        fastMoveInput = player.inputHandler.FastMoveInput;
        jumpInput = player.inputHandler.JumpInput;
        jumpInputStop = player.inputHandler.JumpInputStop;
        grabInput = player.inputHandler.GrabInput;
        scrollInput = player.inputHandler.ScrollInput;
        dashInput = player.inputHandler.DashInput;
    }

    public virtual void PhysicsUpdate() 
    {
        OnCheck();
    }

    public virtual void Exit() 
    {
        
    }

    public virtual void OnCheck() 
    {
        
    }

    public virtual void OnAnimationTrigger() { }

    public virtual void OnAnimationFinish() 
    {
        isAnimationFinish = true;
    }

}
